interfaces/prompting: handle unsupported xattrs
authorZygmunt Krynicki <me@zygoon.pl>
Thu, 21 Aug 2025 18:41:55 +0000 (18:41 +0000)
committerZygmunt Krynicki <me@zygoon.pl>
Thu, 21 Aug 2025 20:46:02 +0000 (20:46 +0000)
This happens in Debian build infrastructure:
```
FAIL: requestrules_test.go:748: requestrulesSuite.TestReadOrAssignUserSessionID

requestrules_test.go:765:
    c.Assert(err, IsNil)
... value syscall.Errno = 0x5f ("operation not supported")
```

Most likely the file system under /run is not a tmpfs or is restricted by a
sandbox of some sort. Allow tests to detect this condition and skip certain
parts.

Signed-off-by: Zygmunt Krynicki <me@zygoon.pl>
Gbp-Pq: Name 0010-interfaces-prompting-handle-unsupported-xattrs.patch

interfaces/prompting/requestrules/requestrules_test.go

index 9f66c1d12f94b62fa1c7f7a3602bdff80303f7d4..b83f24c5e1ea2f8c85075854c8e80656aec46295 100644 (file)
@@ -28,6 +28,7 @@ import (
        "sort"
        "strings"
        "sync"
+       "syscall"
        "testing"
        "time"
 
@@ -762,6 +763,9 @@ func (s *requestrulesSuite) TestReadOrAssignUserSessionID(c *C) {
 
        // If there is a user session dir, expect some non-zero user ID
        origID, err := rdb.ReadOrAssignUserSessionID(1000)
+       if errors.Is(err, syscall.EOPNOTSUPP) {
+               c.Skip("xttrs are not supported on this system")
+       }
        c.Assert(err, IsNil)
        c.Assert(origID, Not(Equals), prompting.IDType(0))
 
@@ -840,14 +844,18 @@ func (s *requestrulesSuite) TestReadOrAssignUserSessionIDConcurrent(c *C) {
        var startWG sync.WaitGroup
        startWG.Add(count)
        resultChan := make(chan prompting.IDType, count)
+       errChan := make(chan error, count)
        for i := 0; i < count; i++ {
                go func() {
                        startWG.Done()
                        <-startChan // wait for broadcast
                        sessionID, err := rdb.ReadOrAssignUserSessionID(5000)
-                       c.Assert(err, IsNil)
-                       c.Assert(sessionID, Not(Equals), prompting.IDType(0))
-                       resultChan <- sessionID
+                       if err != nil {
+                               errChan <- err
+                       } else {
+                               c.Assert(sessionID, Not(Equals), prompting.IDType(0))
+                               resultChan <- sessionID
+                       }
                }()
        }
        startWG.Wait()
@@ -861,6 +869,11 @@ func (s *requestrulesSuite) TestReadOrAssignUserSessionIDConcurrent(c *C) {
        case firstID = <-resultChan:
                c.Assert(firstID, NotNil)
                c.Assert(firstID, Not(Equals), prompting.IDType(0))
+       case err := <-errChan:
+               if errors.Is(err, syscall.EOPNOTSUPP) {
+                       c.Skip("xttrs are not supported on this system")
+               }
+               c.Assert(err, IsNil)
        case <-time.NewTimer(time.Second).C:
                c.Fatal("timed out waiting for first user ID")
        }